﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace MyGames
{
    class ParticleManager
    {
        List<Particle> particles = new List<Particle>();

        #region Public methods
        public void AddParticle(AttackType type, Character reciever, bool crit)
        {
            particles.Add(new Particle(type, reciever, crit));
        }

        public void ClearAll()
        {
            particles.Clear();
        }
        #endregion

        #region Update and Draw
        public void Update(GameTime gameTime)
        {
            for (int i = 0; i < particles.Count; i++)
            {
                // Remove finish projects
                if (particles[i].IsFinished)
                {
                    particles.RemoveAt(i);
                    continue;
                }

                particles[i].Update(gameTime);
            }
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            foreach (Particle particle in particles)
                particle.Draw(spriteBatch);
        }
        #endregion
    }
}
